﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DiemChapNhanThe.Data;
using DiemChapNhanThe.Entities;
using System.Data;

public partial class Controls_ControlFooter : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            Bind_Data1();
            Bind_Data2();
        }
    }
    protected void Bind_Data1()
    {
        int TotallRows = 0;
        TList<LoaiHoTro> Tlist_LoaiHoTro = DataRepository.LoaiHoTroProvider.GetPaged("TenLoaiHoTro like N'%"+ Common.HoTroChung +"%'", "Id DESC", 0, 1, out TotallRows);
        if (Tlist_LoaiHoTro.Count > 0)
        {
            string WhereClause = "TrangThai = 1 and IdLoaiHoTro = " + Tlist_LoaiHoTro[0].Id;
            TList<HoTro> Tlist_HoTro = DataRepository.HoTroProvider.GetPaged(WhereClause, "TenHoTro", 0, 0, out TotallRows);
            dlHoTroChung.DataSource = Tlist_HoTro;
            dlHoTroChung.DataBind();
        }
    }
    protected void Bind_Data2()
    {
        int TotallRows = 0;
        TList<LoaiHoTro> Tlist_LoaiHoTro = DataRepository.LoaiHoTroProvider.GetPaged("TenLoaiHoTro like N'%" + Common.HoTroTichHop + "%'", "Id DESC", 0, 1, out TotallRows);
        if (Tlist_LoaiHoTro.Count > 0)
        {
            string WhereClause = " TrangThai = 1 and IdLoaiHoTro = " + Tlist_LoaiHoTro[0].Id;
            TList<HoTro> Tlist_HoTro = DataRepository.HoTroProvider.GetPaged(WhereClause, "TenHoTro", 0, 0, out TotallRows);
            dlHoTroTichHop.DataSource = Tlist_HoTro;
            dlHoTroTichHop.DataBind();
        }
    }
}